// 引入request方法
import {
  request
} from '../api/aixios-config';
// 登录注册、卡号增删
const apiHome = '/api/service-user/user_service';
// 门锁管理：日常管理、日志记录
const apiLock = '/api/service-lock/lock_service'

// 创建接口调用对象方法
const api = {
  login(data) {
    return request(apiHome + '/sys_login/sys/login', 'post', data);
  },
  register(data) {
    return request(apiHome + '/sys_login/sys/register', 'post', data);
  },
  logOut(){
    return request(`${apiHome}/sys_login/sys/logout`, 'post');
  },
  // 获取用户信息
  getUserInfo(){
    return request(`${apiHome}/sys-user/info`, 'get');
  },
  // 获取用户下所有的锁
  getLockByUsername(username) {
    return request(apiLock + '/lyc-lock/Lock', 'get', username);
  },

  // 门锁管理
  lockOpen(data) {
    return request(apiLock + '/lyc-lock/lock_open', 'get', data);
  },
  lockClose(data) {
    return request(apiLock + '/lyc-lock/lock_close', 'get', data);
  },
  // 操作日志板块
  checkLockOfUser(data){
    return request(`${apiLock}/lyc-lock/lock_checkUser`, 'get', data)
  },
  getAllLoggers(data) {
    return request(apiLock + '/logger/LoggerByUser', 'post', data)
  },
  delLogger(id) {
    return request(apiLock + '/logger/deleteLoggerById', 'get', id);
  },
  
  // getLoggerById() {
  //   return request(apiLock + '/logger/LoggerByLockId', 'get', id);
  // },
  // TCP日志板块
  getTcpLoggers(data){
    return request(apiLock + '/tcp-log/select', 'get', data);
  },
  // 状态日志板块--根据用户名查询所有
  getStateLogger(username){
    return request(apiLock + '/lock-log/selectByUserName', 'get', username);
  },
  // 根据条件筛选
  getStateLoggerByCon(data){
    return request(`${apiLock}/lock-log/selectLocklog`, 'post', data);
  },
  delStateLogger(id){
    return request(apiLock + '/lock-log/deleteById', 'get', id);
  },
  // TODO这个接口先放着：想想能不能有代替方案
  // getLockLoggersByTime(){
  //   return request(apiLock + '/lock-log/select', 'get', data);
  // },

  // 用户卡号管理--超管
  addCardnumber(data){
    return request(`${apiHome}/user-cardnumber/addCardNumber`, 'post', data);
  },
  delCardnumber(data){
    return request(`${apiHome}/user-cardnumber/deleteCardNumber`, 'post', data);
  },
  getCardnumberByUser(data){
    return request(`${apiHome}/user-cardnumber/select_user_list`, 'post', data);
  },
  checkNumber(data){
    return request(`${apiHome}/user-cardnumber/check_user`, 'post', data)
  },
  // 门锁管理--超管
  addLock(data){
    return request(`${apiLock}/lyc-lock/lockAdd`, 'post', data);
  },
  delLock(data){
    return request(`${apiLock}/lyc-lock/lockDeleteById`, 'get', data)
  },
  getUserLock(data){
    return request(`${apiLock}/lyc-lock/Lock`, 'get', data);
  },
  lockAddCard(data){
    return request(`${apiLock}/lock-cardnumber/addCardnumber`, 'post', data)
  },
  // 获取所有锁信息
  getAllLock(){
    return request(`${apiLock}/lyc-lock/LockAll`,'get')
  }


}

// 这一段代码是什么意思？
// 创建axios实例对象：this.$_api
export default function install(Vue) {
  Vue.mixin({
    created() {
      this.$_api = api;
    }
  })
}